/**
 * 2017年4月25日
 */
package util.tags;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

/**
 * @author Alex
 *
 */
public class FormTag extends BaseTag{
	private String action = "/wechat/upload.do";


	
	public void doTag() throws JspException,IOException{
		JspWriter out = getJspContext().getOut();
		String aa = String.format(
								"<form id=\"upload\" method=\"post\" action=\"%s\" enctype=\"multipart/form-data\" target=\"_blank\">"
					        	+"<button class=\"btn btn-primary\" type=\"button\" onclick=\"upload(this)\">选择文件文本文件</button>"
					        	+"<div style=\"overflow: hidden;\">"
					        	+"<label id=\"fn\"></label>"
					        	+"<input id=\"file\" style=\"display:none\" type=\"file\" name=\"file\" onchange=\"change(this)\">"
					        	+ "</div>"
					        	+"<input type=\"submit\" class=\"btn btn-info\" value=\"提交\">"
					        	+ "</form>"
					        	,
					        	this.action
					        	);  
		
		String scrpit ="<script>function change(btn){var file = $(btn).val();if(typeof file == 'string' && file.length>0){$(\"#fn\").html(file);}}function upload(btn){$(\"#file\").click();}</script>";
		out.println(aa);
		out.println(scrpit);
		
		
	}
	
	public void setAction(String action) {
		this.action = action;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
}
